from math import radians
from numpy import square
from manimlib import *

#75cfb8
#bbdfc8
#f0e5d8
#ffc478

class p1(Scene):
    def construct(self):
        # self.add(NumberPlane())
        s=Square(side_length=5).shift(UR*0.5+RIGHT*2)
        ss=s.copy().rotate(300*DEGREES,about_point=[0,3,0])
        # point
        b=s.point_from_proportion(0.75)
        f=ss.point_from_proportion(0.5)
        e=ss.point_from_proportion(0.75)
        o=s.point_from_proportion(0.25)
        c=s.point_from_proportion(0.5)
        # line
        bf=Line(b,f)
        oc=Line(o,c)
        ob=Line(o,b)
        oe=Line(o,e)
        m=line_intersection(oc.get_start_and_end(),bf.get_start_and_end())
        g=line_intersection(oe.get_start_and_end(),bf.get_start_and_end())
        #
        a=Arc(165*DEGREES,105*DEGREES,arc_center=m,radius=0.3)
        tt=Tex(r'\theta').next_to(a,DL,buff=0)
        self.add(s,ss,bf,a,tt)
        self.add(Tex('A').next_to(s,UL),Tex('B').next_to(s,UR),Tex('C').next_to(s,DR),Tex('D').next_to(s,DL),Tex('B^\prime').move_to([2.7,-1,0]),Tex('C^\prime').move_to([-2.2,-3.8,0]),Tex('D^\prime').move_to([-4.6,0.5,0]))
        self.wait()
class p2(Scene):
    def construct(self):
        # self.add(NumberPlane())
        s=Square(side_length=5).shift(UR*0.5+RIGHT*2)
        ss=s.copy().rotate(300*DEGREES,about_point=[0,3,0])
        # point
        b=s.point_from_proportion(0.75)
        f=ss.point_from_proportion(0.5)
        e=ss.point_from_proportion(0.75)
        o=s.point_from_proportion(0.25)
        c=s.point_from_proportion(0.5)
        # line
        bf=Line(b,f)
        oc=Line(o,c)
        ob=Line(o,b)
        oe=Line(o,e)
        m=line_intersection(oc.get_start_and_end(),bf.get_start_and_end())
        g=line_intersection(oe.get_start_and_end(),bf.get_start_and_end())
        #
        a=Arc(165*DEGREES,105*DEGREES,arc_center=m,radius=0.3)
        tt=Tex(r'\theta').next_to(a,DL,buff=0)
        self.add(s,ss,bf,a,tt)
        self.add(ob,oe)
        poly=Polygon(o,g,b).set_fill(color='#75cfb8',opacity=0.5)
        self.add(poly)
        poly1=Polygon(m,c,b).set_fill(color='#ffc478',opacity=0.5)
        self.add(poly1)
        self.add(Elbow(angle=345*DEGREES).move_to(g).shift(RIGHT*0.2+UP*0.1),Elbow().next_to(c,UR,buff=0))
        self.add(Tex('A').next_to(s,UL),Tex('B').next_to(s,UR),Tex('C').next_to(s,DR),Tex('D').next_to(s,DL),Tex('B^\prime').move_to([2.7,-1,0]),Tex('C^\prime').move_to([-2.2,-3.8,0]),Tex('D^\prime').move_to([-4.6,0.5,0]))
        self.wait()
class p3(Scene):
    def construct(self):
        # self.add(NumberPlane())
        s=Square(side_length=5).shift(UR*0.5+RIGHT*2)
        ss=s.copy().rotate(300*DEGREES,about_point=[0,3,0])
        # point
        b=s.point_from_proportion(0.75)
        f=ss.point_from_proportion(0.5)
        e=ss.point_from_proportion(0.75)
        o=s.point_from_proportion(0.25)
        c=s.point_from_proportion(0.5)
        # line
        bf=Line(b,f)
        oc=Line(o,c)
        ob=Line(o,b)
        oe=Line(o,e)
        m=line_intersection(oc.get_start_and_end(),bf.get_start_and_end())
        g=line_intersection(oe.get_start_and_end(),bf.get_start_and_end())
        #
        a=Arc(300*DEGREES,60*DEGREES,arc_center=o,radius=0.3)
        tt=Tex(r'\theta').next_to(a,DR,buff=0).shift(UP*0.1+RIGHT*0.2)
        self.add(s,ss,bf,a,tt)
        self.add(Tex('A').next_to(s,UL),Tex('B').next_to(s,UR),Tex('C').next_to(s,DR),Tex('D').next_to(s,DL),Tex('B^\prime').move_to([2.7,-1,0]),Tex('C^\prime').move_to([-2.2,-3.8,0]),Tex('D^\prime').move_to([-4.6,0.5,0]))
        self.wait()
class p4(Scene):
    def construct(self):
        # self.add(NumberPlane())
        s=Square(side_length=5).shift(UR*0.5+RIGHT*2)
        ss=s.copy().rotate(300*DEGREES,about_point=[0,3,0])
        # point
        b=s.point_from_proportion(0.75)
        f=ss.point_from_proportion(0.5)
        e=ss.point_from_proportion(0.75)
        o=s.point_from_proportion(0.25)
        c=s.point_from_proportion(0.5)
        # line
        bf=Line(b,f)
        oc=Line(o,c)
        ob=Line(o,b)
        oe=Line(o,e)
        m=line_intersection(oc.get_start_and_end(),bf.get_start_and_end())
        g=line_intersection(oe.get_start_and_end(),bf.get_start_and_end())
        #
        a=Arc(300*DEGREES,60*DEGREES,arc_center=o,radius=0.3)
        tt=Tex(r'\theta').next_to(a,DR,buff=0).shift(UP*0.1+RIGHT*0.2)
        self.add(s,ss,bf,a,tt,ob,oe)
        self.add(Elbow(angle=345*DEGREES).move_to(g).shift(RIGHT*0.2+UP*0.1),Elbow().next_to(c,UR,buff=0))
        alpha=Arc(255*DEGREES,60*DEGREES,arc_center=o,radius=0.4,stroke_color='#75cfb8')
        beta=Arc(300*DEGREES,15*DEGREES,arc_center=o,radius=0.5,stroke_color='#ffc478')
        self.add(alpha,beta,Tex(r'\alpha',color='#75cfb8').next_to(alpha,DOWN,buff=0.1).shift(RIGHT*0.05),Tex(r'\beta',color='#ffc478').next_to(beta,DR,buff=0).shift(DOWN*0.1+RIGHT*0.1))
        self.add(Tex('A').next_to(s,UL),Tex('B').next_to(s,UR),Tex('C').next_to(s,DR),Tex('D').next_to(s,DL),Tex('B^\prime').move_to([2.7,-1,0]),Tex('C^\prime').move_to([-2.2,-3.8,0]),Tex('D^\prime').move_to([-4.6,0.5,0]))
        self.wait()